﻿@{
    ViewBag.Title = "SearchRoomDetails";
    Layout = "~/Views/Shared/_Form.cshtml";
}

<script>
    var keyValue = request('keyValue');
    var Id = "";
    var State = -1, Memo = "", organizeid = "";
    $(function () {
        InitialPage();
    })
    //初始化界面
    function InitialPage() {
        $("#State").ComboBox({
            //  url: " ",
            data: [{ "key": "2", "value": "未完成" }, { "key": "3", "value": "已完成" }, { "key": "4", "value": "已取消" }],
            id: "key",
            text: "value",
            description: "=单据执行状态=",
            height: "150px",
            click: function (e) {
                if (e.attr('data-value') > 2) {
                    $(".BassClass").removeAttr("disabled");
                    $("#Submit1").removeAttr("disabled");
                } else {
                    $(".BassClass").attr("disabled", "disabled");
                    $("#Submit1").attr("disabled", "disabled");
                }

            }
        });
        $("#OrganizeId").ComboBoxTree({
            url: "../../ResourceManage/RS_Device/GetOrganizeTree",
            description: "==所属机构==",
            height: "250px",
            click: function (data) {
            }
        });
        if (!!keyValue) {
            $.SetForm({
                url: "../../QualificationManage/SearchRoom/GetBillInfo",
                param: { BillCode: keyValue },
                success: function (data) {
                    Id = data.BillInfo.Id;
                    State = data.BillInfo.State
                    organizeid = data.BillInfo.OrganizeId;
                    if (State > 1) {
                        $("#Chk").attr("disabled", "disabled");
                        $("#Submit").attr("disabled", "disabled");
                        $("#Unchk").attr("disabled", "disabled");
                        $("#Try").attr("hidden", "hidden");
                        $("#Try1").removeAttr("hidden");
                        $("#Chk").attr("checked", "checked");
                        $(".BassClass1").attr("disabled", "disabled");
                        $(".BassClass").removeAttr("disabled");
                    }
                    if (State == 0) {
                        $("#Chk").attr("disabled", "disabled");
                        $("#Submit").attr("disabled", "disabled");
                        $("#Unchk").attr("disabled", "disabled");
                        $("#Unchk").attr("checked", "checked");
                        $("#Try").removeAttr("hidden");
                        $("#Try1").attr("hidden", "hidden");
                        $("#ApprovalDescription").attr("disabled", "disabled");
                        $("#ApprovalDescription").val(Memo);
                    }
                    if (State === "" || State == 1 || State == 2 || State == 5) {

                        $(".BassClass").attr("disabled", "disabled");
                        $("#Submit1").attr("disabled", "disabled");

                    }
                    if (State == 5 || State == 3) {
                        $("#Unchk").attr("checked", "checked");
                        $("#Try").removeAttr("hidden");
                        $("#Try1").attr("hidden", "hidden");
                        $("#ApprovalDescription").attr("disabled", "disabled");
                        $("#ApprovalDescription").val(Memo);
                        $("#State").attr("disabled", "disabled");
                    }
                    if (State == 3) {
                        $("#Unchk").attr("checked", "checked");
                        $("#Try").removeAttr("hidden");
                        $("#Try1").attr("hidden", "hidden");
                        $("#ApprovalDescription").attr("disabled", "disabled");
                        $("#ApprovalDescription").val(Memo);
                        $("#State").attr("disabled", "disabled");
                        $("#Submit1").attr("disabled", "disabled");
                        $("#RealTime").attr("disabled", "disabled");
                        $("#RealMan").attr("disabled", "disabled");
                        $("#RealPhone").attr("disabled", "disabled");
                        $("#SeeRoomInfo").attr("disabled", "disabled");
                    }
                    $("#State").ComboBoxSetValue(data.BillInfo.State);
                    $("#ZX").SetWebControls(data.BillInfo);
                    if (State > 1) {
                        $("#JH").SetWebControls(data.BillInfo);
                    }
                    $("#Info").SetWebControls(data.RoomInfo);
                    $("#Info").SetWebControls(data.MemberInfo);
                    $("#Info").SetWebControls(data.BillInfo);

                    var State = "";
                    switch (data.RState) {
                        case -1:
                            State = "未知";
                            break;
                        case 1:
                            State = "空置";
                            break;
                        case 2:
                            State = "已租";
                            break;
                        case 3:
                            State = "自用";
                            break;
                        default:
                            break;
                    }
                    $("#RState").val(State);
                    if (data.MemberInfo.Sex == 1 && data.MemberInfo != null) {
                        $("#Sex").val("男");
                    }
                    else if (data.MemberInfo.Sex == 2 && data.MemberInfo != null) {
                        $("#Sex").val("女");
                    }
                    else {
                        $("#Sex").val("");
                    }
                }
            })
        }
        $("input").attr("disabled", "disabled");
        $("textarea").attr("disabled", "disabled");
        $("#State").attr("disabled", "disabled");
    };
    //审批结果
    function Rdo_Sumbit(a) {
        State = a;
        if (a == 1) {
            $("#Try").attr("hidden", "hidden");
            $("#Try1").removeAttr("hidden");
        }
        else {
            $("#Try1").attr("hidden", "hidden");
            $("#Try").removeAttr("hidden");
        }
    };
    //带看人词典
    function GetMan(a) {
        var options = "";
        switch (a) {
            case 1: //计划带看人
                options = "?keyValue=PlanMan&objectA=PlanManId&objectB=PlanPhone&&type=3&organizeid=" + organizeid;

                break;
            case 2: //实际带看人
                if (State === "" || State == 1 || State == 5) {
                    return false;
                }
                options = "?keyValue=RealMan&objectA=RealManId&objectB=Realphone&&type=3&organizeid=" + organizeid;
                break;

            default: break;

        }

        DataItemClick(options);
    };
</script>
<style>
    .form {
        width: 90%;
        margin-left: 5%;
    }

    #Info td {
        border: 1px solid #ccc;
        height: 40px;
    }

    .cs_1 {
        border: none;
    }

    .cs2 {
        border: 1px solid #ccc;
        height: 40px;
        background-color: #DDF0ED;
    }

    #OrganizeId div {
        border: none;
    }
</style>
<div style="margin-top: 20px; ">
    <table class="form" id="Info">
        <tr>
            <td class="formTitle cs2">所属机构</td>
            <td class="formValue" colspan="4"> <div id="OrganizeId" type="selectTree" readonly class="ui-select cs_1"></div> </td>
            <td class="formTitle cs2">单据编号</td>
            <td class="formValue" colspan="4"><input class="form-control cs_1" readonly id="BillCode" type="text" /></td>
            <td class="formTitle cs2">单据日期</td>
            <td class="formValue" colspan="2"><input class="form-control cs_1" readonly id="Date" type="text" /></td>
        </tr>
        <tr>
            <td class="formTitle cs2">看房地址</td>
            <td class="formValue" colspan="9"><input class="form-control cs_1" readonly id="AllName" type="text" /></td>
            <td class="formTitle cs2">房间状态</td>
            <td class="formValue" colspan="2"> <input class="form-control cs_1" readonly id="RState" type="text" /></td>
        </tr>
        <tr>
            <td class="formTitle cs2">姓名</td>
            <td class="formValue" colspan="2"><input class="form-control cs_1" readonly id="Name" type="text" /></td>
            <td class="formTitle cs2">身份证号</td>
            <td class="formValue" colspan="3"><input class="form-control cs_1" readonly id="IDCard" type="text" /></td>
            <td class="formTitle cs2">性别</td>
            <td class="formValue" colspan="2"><input class="form-control cs_1" readonly id="Sex" type="text" /></td>
            <td class="formTitle cs2">民族</td>
            <td class="formValue" colspan="2"><input class="form-control cs_1" readonly id="Nation" type="text" /></td>
        </tr>
        <tr>
            <td class="formTitle cs2">文化程度</td>
            <td class="formValue" colspan="2"><input class="form-control cs_1" readonly id="Cultural" type="text" /></td>
            <td class="formTitle cs2">手机号码</td>
            <td class="formValue" colspan="3"><input class="form-control cs_1" readonly id="Phone" type="text" /></td>
            <td class="formTitle cs2">固定电话</td>
            <td class="formValue" colspan="2"><input class="form-control cs_1" readonly id="PhoneNum" type="text" /></td>
            <td class="formTitle cs2">婚姻状况</td>
            <td class="formValue" colspan="2"><input class="form-control cs_1" readonly id="MarryInfo" type="text" /></td>
        </tr>
        <tr>
            <td class="formTitle cs2">期望看房时间</td>
            <td class="formValue" colspan="12"><input class="form-control cs_1" readonly id="ExpectTime" type="text" /></td>
        </tr>
        <tr>
            <td class="formTitle cs2">其他说明</td>
            <td class="formValue" colspan="12"><textarea class="form-control cs_1" readonly id="Description" style="height:50px;"></textarea></td>
        </tr>

    </table>
    <table class="form" id="JH">
        <tr style=" height: 20px; border-bottom: 1px dashed #cecece;"><td colspan="9"></td> </tr>
        <tr style="height:20px;"></tr>
        <tr>
            <td class="formTitle ">审批结果</td>
            <td class="formValue"><input id="Chk" name="Sumbit" type="radio" onchange="Rdo_Sumbit(1)" value="1" />同意</td>
            <td class="formValue"><input id="Unchk" name="Sumbit" type="radio" onchange="Rdo_Sumbit(0)" value="0" />不同意</td>
            <td colspan="6"></td>
        </tr>
        <tr id="Try1">
            <td class="formTitle">计划看房时间</td>
            <td class="formValue" colspan="2"><input id="PlanTime" type="text" class="form-control input-wdatepicker BassClass1 " placeholder="请输入计划带看时间" value="@LeSoft.Util.Time.GetToday("yyyy-MM-dd HH:mm:ss")" onfocus="WdatePicker({ dateFmt: 'yyyy-MM-dd HH:mm:ss' })" /></td>
            <td class="formTitle">预约带看人</td>
            <td class="formValue" colspan="2">
                <div class="input-group" style="width: 100%;">
                    <input id="PlanManId" class="form-control" type="hidden" value="@ViewBag.ManId" />
                    <input id="PlanMan" type="text" class="form-control  BassClass1" value="@ViewBag.Man" />
                    <span class="input-group-btn">
                        <a onclick="GetMan(1);" class="form-control BassClass1 " style="cursor: pointer "><i class="fa fa fa-book BassClass1" style=" font-size: 20px; padding-right: 5px; padding-top: 5px; color: gray"></i></a>
                    </span>
                </div>
            </td>
            <td class="formTitle">带看人联系方式</td>
            <td class="formValue" colspan="2"><input class="form-control BassClass1" id="PlanPhone" type="text" value="@ViewBag.Phone" /></td>

        </tr>
        <tr id="Try">
            <td class="formTitle">不同意原因</td>
            <td class="formValue" colspan="8"><textarea class="form-control" id="ApprovalDescription" style="height:50px;"></textarea></td>
        </tr>
        <tr style=" height: 20px; border-bottom: 1px dashed #cecece;"><td colspan="9"></td> </tr>
        <tr style="height:20px;"></tr>
    </table>
    <table class="form" id="ZX">
        <tr>
            <td class="formTitle">执行状态</td>

            <td class="formValue" colspan="2"><div id="State" type="select" isvalid="yes" checkexpession="NotNull" class="ui-select  "></div></td>
        </tr>

        <tr>
            <td class="formTitle">实际看房时间</td>
            <td class="formValue" colspan="2"><input id="RealTime" isvalid="yes" checkexpession="NotNull" type="text" class="form-control input-wdatepicker  BassClass " placeholder="请输入实际带看时间" onfocus="WdatePicker({ dateFmt: 'yyyy-MM-dd HH:mm:ss' })" /></td>
            <td class="formTitle">实际带看人</td>
            <td class="formValue" colspan="2">
                <div class="input-group" style="width: 100%;">
                    <input id="RealManId" class="form-control" type="hidden" />
                    <input id="RealMan" type="text" isvalid="yes" checkexpession="NotNull" class="form-control BassClass " />
                    <span class="input-group-btn">
                        <a onclick="GetMan(2);" class="form-control BassClass" style="cursor: pointer "><i class="fa fa fa-book BassClass" style=" font-size: 20px; padding-right: 5px;padding-top:5px;  color: gray"></i></a>
                    </span>
                </div>
            </td>

            <td class="formTitle">带看人联系方式</td>
            <td class="formValue" colspan="2"><input class="form-control BassClass" isvalid="yes" checkexpession="NotNull" id="RealPhone" type="text" /></td>
        </tr>
        <tr>
            <td class="formTitle">看房情况说明</td>
            <td class="formValue" colspan="8"><textarea class="form-control BassClass" id="SeeRoomInfo" style="height:50px;"></textarea></td>
        </tr>
    </table>

</div>
